package com.ruoyi.decision.service.impl;

import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.decision.domain.Menu;
import com.ruoyi.decision.domain.Scene;
import com.ruoyi.decision.domain.StrategyClassification;
import com.ruoyi.decision.mapper.StrategyClassificationMapper;
import com.ruoyi.decision.service.IStrategyClassificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.UUID;

/**
 * 优化策略分类Service业务层处理
 * 
 * @author zbw
 * @date 2022-07-20
 */
@Service
public class StrategyClassificationServiceImpl implements IStrategyClassificationService 
{
    @Autowired
    private StrategyClassificationMapper strategyClassificationMapper;

    /**
     * 查询优化策略分类
     * 
     * @param strategyTypeId 优化策略分类主键
     * @return 优化策略分类
     */
    @Override
    public StrategyClassification selectStrategyClassificationByStrategyTypeId(String strategyTypeId)
    {
        return strategyClassificationMapper.selectStrategyClassificationByStrategyTypeId(strategyTypeId);
    }

    /**
     * 查询优化策略分类列表
     * 
     * @param strategyClassification 优化策略分类
     * @return 优化策略分类
     */
    @Override
    public List<StrategyClassification> selectStrategyClassificationList(StrategyClassification strategyClassification)
    {
        return strategyClassificationMapper.selectStrategyClassificationList(strategyClassification);
    }

    /**
     * 新增优化策略分类
     * 
     * @param strategyClassification 优化策略分类
     * @return 结果
     */
    @Override
    public int insertStrategyClassification(StrategyClassification strategyClassification)
    {
        String strategyTypeId = UUID.randomUUID().toString().toLowerCase(Locale.ROOT).replace("-","");
        strategyClassification.setStrategyTypeId(strategyTypeId);
        return strategyClassificationMapper.insertStrategyClassification(strategyClassification);
    }

    /**
     * 修改优化策略分类
     * 
     * @param strategyClassification 优化策略分类
     * @return 结果
     */
    @Override
    public int updateStrategyClassification(StrategyClassification strategyClassification)
    {
        return strategyClassificationMapper.updateStrategyClassification(strategyClassification);
    }

    /**
     * 批量删除优化策略分类
     * 
     * @param strategyTypeIds 需要删除的优化策略分类主键
     * @return 结果
     */
    @Override
    public int deleteStrategyClassificationByStrategyTypeIds(String[] strategyTypeIds)
    {
        return strategyClassificationMapper.deleteStrategyClassificationByStrategyTypeIds(strategyTypeIds);
    }

    /**
     * 删除优化策略分类信息
     * 
     * @param strategyTypeId 优化策略分类主键
     * @return 结果
     */
    @Override
    public int deleteStrategyClassificationByStrategyTypeId(String strategyTypeId)
    {
        return strategyClassificationMapper.deleteStrategyClassificationByStrategyTypeId(strategyTypeId);
    }

    @Override
    public List<Menu> treemenu() {
        List<Menu> data = new ArrayList<>();
        List<StrategyClassification> strategyClassifications = strategyClassificationMapper.selectStrategyClassificationList(null);
        for (StrategyClassification b : strategyClassifications) {
            Menu vo = new Menu();
            vo.setId(b.getStrategyTypeId());
            vo.setName(b.getStrategyTypeName());
            vo.setpId(b.getFatherId());
            data.add(vo);
        }

        return data;
    }
}
